using System;
using System.Collections.Generic;
using NHibernate;
using RMH.Entities;

namespace RMH.DataAccess
{
    public class StayRepository : RepositoryBase<Stay>, IStayRepository
    {
        public StayRepository(ISession session)
            : base(session)
        {
        }

        public IList<Stay> GetCurrentStays()
        {
                       
            string hql = @"FROM Stay WHERE CheckinDate <= :now 
                    AND (CheckoutDate IS NULL OR CheckoutDate >= :now)";

            var query = getQuery(hql);
            query.SetDateTime("now", DateTime.Now);
            return query.List<Stay>();
        }

		public IList<Stay> GetByDateRange(DateTime startDate, DateTime endDate) {
			string hql = @"FROM Stay WHERE CheckInDate BETWEEN :startDate and :endDate";
			var query = getQuery(hql);
			query.SetDateTime("startDate", startDate);
			query.SetDateTime("endDate", endDate);
			return query.List<Stay>();
		}
        
    }
}